
--migração de orçamentos
set identity_insert OrcamentoC on
insert into OrcamentoC(
Codigo,
CodCliente,
TotalOrcamento,
DataMovimento,
Status,
CodEmp,
CodVendedor,
NomeVendedor,
DataHora,
Usuario,
Placa,
DescricaoCliente)
select 
sec.Codigo_orc,
sec.Codigo_cli,
0,
Data_orc,
'A',
1,
Codigo_ven,
'',
Data_orc,
UserName_usr,
Placa_orc,
discriminacaocli_orc
from Dados_db..OrcamentoC_tb as sec
set identity_insert OrcamentoC off

-- atualiza o nome do vendedor
update OrcamentoC
set NomeVendedor = trib.Nome
from (select Codigo, Nome from Vendedor) as Trib
where trib.Codigo = OrcamentoC.CodVendedor;


update OrcamentoC
set NomeCliente = trib.Nome
from (select Codigo, Nome from Cliente) as Trib
where trib.Codigo = OrcamentoC.CodCliente;

update orcamentoC set Status = 'ABERTO'
